const express = require('express');
const router = express.Router();
const variableController = require('../controllers/variableController');

// 全局变量相关路由
router.get('/variables/global', variableController.getGlobalVariables);
router.post('/variables/global', variableController.saveGlobalVariable);
router.delete('/variables/global/:id', variableController.deleteGlobalVariable);

// 事件局部变量相关路由
router.get('/variables/event/:eventId', variableController.getEventVariables);
router.post('/variables/event/:eventId', variableController.saveEventVariable);
router.delete('/variables/event/:eventId/:id', variableController.deleteEventVariable);
router.delete('/variables/event/:eventId/clear', variableController.clearEventVariables);

// 获取事件所有可用变量（全局+局部）
router.get('/variables/event/:eventId/all', variableController.getAllVariablesForEvent);

// 获取变量被哪些事件使用
router.get('/variables/:variableType/:variableId/usage', variableController.getVariableUsage);

module.exports = router; 